package ru.urfc.portal.rest;

import java.util.Arrays;
import java.util.List;

import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import ru.urfc.portal.model.documents.AdditionalDevice;

@Produces({MediaType.APPLICATION_XML, MediaType.TEXT_XML, MediaType.APPLICATION_JSON})
@Path("clients/{clientId}/documents/{documentId}/additional-devices")
public class DocumentAdditionalDeviceService {

	@GET
	public List<AdditionalDevice> listNewDevices(@PathParam("clientId") Long clientId,
			@PathParam("documentId") Long documentId) {
		return Arrays.asList(
				new AdditionalDevice(11L, "РЭС 123", "33", "Маяк 22", 100, true, 1000, 33.66D, 123.23D, 22.22D, "Челябинск",
						new Double[] {10D, 20D, 10D, 20D, 10D, 20D, 10D, 20D, 10D, 20D, 10D, 20D, 10D, 20D}),
				new AdditionalDevice(12L, "РЭС 143", "42", "Маяк 22", 100, true, 1000, 33.66D, 123.23D, 22.22D, "Челябинск", null),
				new AdditionalDevice(13L, "РЭС 133", "34", "Маяк 22", 100, true, 1000, 33.66D, 123.23D, 22.22D, "Челябинск", null)
		);
	}
	
	@POST
	@Path("{deviceId}")
	public AdditionalDevice createDevice(@PathParam("clientId") Long clientId,
			@PathParam("documentId") Long documentId, AdditionalDevice additionalDevice) {
		return getDevice(clientId, documentId, 123L);
	}

	@GET
	@Path("{deviceId}")
	public AdditionalDevice getDevice(@PathParam("clientId") Long clientId,
			@PathParam("documentId") Long documentId, @PathParam("deviceId") Long deviceId) {
		return new AdditionalDevice(deviceId, "РЭС 123", "33", "Маяк 22", 100, true, 1000, 33.66D, 123.23D, 22.22D, "Челябинск",
				new Double[] {10D, 20D, 10D, 20D, 10D, 20D, 10D, 20D, 10D, 20D, 10D, 20D, 10D, 20D});
	}
	
	@PUT
	@Path("{deviceId}")
	public void updateDevice(@PathParam("clientId") Long clientId,
			@PathParam("documentId") Long documentId, @PathParam("deviceId") Long deviceId,
			AdditionalDevice additionalDevice) {
	}

	@DELETE
	@Path("{deviceId}")
	public void deleteDevice(@PathParam("clientId") Long clientId, @PathParam("documentId") Long documentId,
			@PathParam("deviceId") Long deviceId) {
	}

}
